define(function(require, exports, module) {
  'use strict';

  var Search = require('../common/search/search');

  var opts = [
    '<a href="javascript:;" data-id="{{id}}" data-role="edit">编辑</a>',
    '<a href="javascript:;" data-role="del">删除</a>'
  ];
  new Search({
    url: 'questionList',
    delUrl: 'questionDel',
    keepHistory: false,
    dateCfg: {
      disabled: true
    },
    formCfg: {
      buttons: [{
        colspan: null,
        'class': 'pull-right',
        value: '<i class="fa fa-plus"></i> 添加题库',
        attrs: {
          type: 'button',
          'class': 'btn btn-default btn-info',
          'data-role': 'add'
        }
      }],
      data: {
        groups: [{
          // label: '页面名称',
          colspan: null,
          attrs: {
            type: 'text',
            name: 'docSubject',
            maxlength: 30,
            placeholder: '标题'
          }
        }, {
          // label: '所属模板',
          colspan: null,
          attrs: {
            type: 'hidden',
            name: 'cateId',
            placeholder: '分类'
          }
        }, {
          colspan: null,
          value: '<i class="fa fa-search"></i> 搜索',
          attrs: {
            type: 'submit'
          }
        }]
      }
    },
    gridCfg: {
      columns:[
        {key:'id', name: '序号'},
        {key:'docSubject', name: '标题'},
        {key:'reprintNum', name: '转换量'},
        {key:'visitNum', name: '浏览量'},
        {key:'trueRate', name: '答题正确率'},
        {key:'docCreateTime', name: '创建时间'},
        {name: '操作', template: opts.join('')}
      ]
    },
    delegates: {
      'click [data-role=add]': function() {
        window.location.href = '/admin/question/add.html';
      },
      'click [data-role=edit]': function(e) {
        window.location.href = '/admin/question/edit.html?id=' + e.currentTarget.dataset.id;
      }
    }
  });
});
